package com.example.service;

import cn.hutool.json.JSONUtil;
import com.example.dao.PathInfoDao;
import org.springframework.stereotype.Service;
import com.example.entity.PathInfo;
import com.example.entity.AuthorityInfo;
import com.example.entity.Account;
import com.example.vo.PathInfoVo;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import org.springframework.beans.factory.annotation.Value;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;

@Service
public class PathInfoService {

    @Resource
    private PathInfoDao pathInfoDao;

    public PathInfo add(PathInfo info) {
        pathInfoDao.insertSelective(info);
        return info;
    }

    public void delete(Long id) {
        pathInfoDao.deleteByPrimaryKey(id);
    }

    public void update(PathInfo info) {
        pathInfoDao.updateByPrimaryKeySelective(info);
    }

    public PathInfo findById(Long id) {
        return pathInfoDao.selectByPrimaryKey(id);
    }

    public List<PathInfoVo> findAll() {
        return pathInfoDao.findAll();
    }

    public PageInfo<PathInfoVo> findPage(String name, String station, String start, String end,
                                        String startTime, String endTime, Integer pageNum, Integer pageSize, HttpServletRequest request) {
        PageHelper.startPage(pageNum, pageSize);
        List<PathInfoVo> all = pathInfoDao.findAllPage(name, station ,start, end, startTime, endTime);
        return PageInfo.of(all);
    }
}
